<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!--
    This file is part of apache-geo-map.

    Apache-Geo-Map is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Foobar is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.

-->

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title/>Apache-Geo-Map Example</title>
	<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<YOUR_API_KEY>" type="text/javascript"></script>

  </head>
  <body onunload="GUnload()">

<h1>Apache-Geo-Map Example Page</h1>

           <div id="map" style="width: 850px; height: 600px"></div>

    <noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b> 
      However, it seems JavaScript is either disabled or not supported by your browser. 
      To view Google Maps, enable JavaScript by changing your browser options, and then 
      try again.
    </noscript>


    <script type="text/javascript">

    if (GBrowserIsCompatible()) {
      var side_bar_html = "";
    
      var gmarkers = [];
      var htmls = [];
      var i = 0;
      
      var gicons = [];
      gicons["blue"] = new GIcon(G_DEFAULT_ICON, "./img/blue.png");
      gicons["yellow"] = new GIcon(G_DEFAULT_ICON, "./img/yellow.png");

      function createMarker(point,name,html,icontype) {
        var marker = new GMarker(point, gicons[icontype]);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        gmarkers[i] = marker;
        htmls[i] = html;
        side_bar_html += '<a href="javascript:myclick(' + i + ')">' + name + '</a><br>';
        i++;
        return marker;
      }


      function myclick(i) {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }


      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(51.499633, -0.709283), 2);


      var request = GXmlHttp.create();
      request.open("GET", "data.xml", true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          var xmlDoc = GXml.parse(request.responseText);
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");
          
          for (var i = 0; i < markers.length; i++) {
            var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
            var point = new GLatLng(lat,lng);
            var html = markers[i].getAttribute("html");
            var label = markers[i].getAttribute("label");
            var icontype = markers[i].getAttribute("icon");
            var marker = createMarker(point,label,html,icontype);
            map.addOverlay(marker);
          }
          document.getElementById("side_bar").innerHTML = side_bar_html;
        }
      }
      request.send(null);
    }

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
    </script>
	<center>
	<hr>
	<a href="http://dev.squarecows.com"><img border= "no" src="./img/squarecows.png" alt="squarecows.com"/></a><br/>
	Generated by Development/Beta Version
	</center>
  </body>

</html>




